package com.wb.business.service.aqoeous;

import com.wb.business.domain.qo.GetBusinessInventoryReserveLabelQO;
import com.wb.business.config.BusinessEntityManager;
import com.wb.business.service.BusinessEntityService;
import org.shoukaiseki.aqoeous.scan.Aqoeous;
import org.shoukaiseki.aqoeous.service.IAqoeous;
import org.shoukaiseki.common.utils.NumberUtils;
import org.shoukaiseki.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 **/
@Service
@Aqoeous(qoClass = GetBusinessInventoryReserveLabelQO.class )
public class BusinessInventoryReserveLabelQueryServiceImpl implements IAqoeous<GetBusinessInventoryReserveLabelQO> {

    @Autowired
    private BusinessEntityManager businessEntityManager;

    @Override
    public <T> List<? super T> aqoeous(GetBusinessInventoryReserveLabelQO qo) {
        BusinessEntityService businessEntityService = businessEntityManager.getBusinessEntityService(qo.getOwnerName());
        if (businessEntityService==null) {
            return List.of("");
        }
        if (NumberUtils.isNullOrZero(qo.getOwnerId())) {
            return List.of("");
        }
        String inventoryReserveLabel = businessEntityService.getBusinessInventoryReserveLabel(qo.getOwnerId());
        return List.of(StringUtils.defaultIfEmpty(inventoryReserveLabel,""));
    }

}